#include<iostream>
using namespace std;
const int N = 1e5 + 10;
int w[N];
int f[N][2];
int n;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> w[i];
	f[0][0] = 0, f[0][1] = -0x3f3f3f3f;
	for (int i = 1; i <= n; i++) {
		f[i][0] = max(f[i - 1][0], f[i - 1][1]);
		f[i][1] = f[i - 1][0] + w[i];
	}
	cout << max(f[n][0], f[n][1]) << endl;
	return 0;
}